/*****************************************************************************\

File:   otkQuickPrint.java

Date          Build     Author        Version   Comments
28-Aug-12    P-20-12    asonar         $$1       Created
18-Oct-12    P-20-15    asonar         $$2       Dumped info in a file
14-Jul-14    P-20-56    aphatak        $$3       Import pfcBase.*; for
						 DisplayStyle
20-mar-15 P-30-05 gshmelev $$4  called GetCurrentSession

\****************************************************************************/

package com.ptc.otkjavaexamples;

import com.ptc.cipjava.*;
import com.ptc.pfc.pfcSession.*;
import com.ptc.pfc.pfcCommand.*;
import com.ptc.pfc.pfcGlobal.*;
import com.ptc.pfc.pfcModel.*;
import com.ptc.pfc.pfcModelItem.*;
import com.ptc.pfc.pfcFeature.*;
import com.ptc.pfc.pfcSolid.*;
import java.io.*;

import com.ptc.pfc.pfcFamily.*;
import com.ptc.pfc.pfcWindow.*;
import com.ptc.wfc.wfcSession.*;
import com.ptc.pfc.pfcExceptions.*;
import com.ptc.wfc.wfcSolid.*;
import com.ptc.pfc.pfcExceptions.XPFC.*; 
import com.ptc.wfc.wfcQuickPrint.*;
import com.ptc.pfc.pfcBase.*;

/*====================================================================*\
FUNCTION : otkQuickPrint
PURPOSE  : This examples executes quick print of a given solid model.
\*====================================================================*/

class otkQuickPrint extends DefaultUICommandActionListener
{
 
	public void otkQuickPrint()
	{
	} 
	 
	public void OnCommand()
	{
		addQuickPrint();
	} 
	 
	public void addQuickPrint()
{
    try
      {
	  
    FileWriter file = new FileWriter ("QuickPrint_info.txt");
    BufferedWriter fp_out_Quick_Print = new BufferedWriter(file);		  
	  
	Session session = pfcSession.GetCurrentSession();
	WSession ses = (WSession)session;
	
    	Model model = ses.GetCurrentModel();

		if (model != null)
		{
			fp_out_Quick_Print.write("Model name: " + model.GetInstanceName() );
			fp_out_Quick_Print.newLine();
			System.out.println("Model name: " + model.GetInstanceName());
		}
		else
			throw new Exception("Method: otkQuickPrint \nMsg: Current model is NULL");


		if ( model == null || ( model.GetType() != ModelType.MDL_PART && model.GetType() != ModelType.MDL_ASSEMBLY ))
			throw new Exception("Method: otkQuickPrint \nMsg: Current model is not a solid model");

		Window win = ses.GetModelWindow(model);

		if (win != null)
		{

		  Solid solidModel = (Solid)model;
                  
                  WSolid wSolid = (WSolid)solidModel;
                  
                  QuickPrintInstructions quickPInstr = wfcQuickPrint.QuickPrintInstructions_Create();
                  
                  quickPInstr.SetLayoutType(QuickPrintLayoutType.QPRINT_LAYOUT_MANUAL);
                  
                  quickPInstr.SetManualLayoutType (QuickPrintManual3View.QPRINTMANUAL_3VIEW_1_23VERT);
                  
                  DrawingViewDisplay viewDisplayStyle1 = 
				  wfcQuickPrint.DrawingViewDisplay_Create (DisplayStyle.DISPSTYLE_WIREFRAME, false, TangentEdgeDisplay.TANEDGE_SOLID, CableDisplay.CABLEDISP_DEFAULT, false, false);
                  
				  QuickPrintGeneralViewInsructions generalViewInstruction1v = 
				  wfcQuickPrint.QuickPrintGeneralViewInsructions_Create(QuickPrintGeneralViewLocation.QPRINT_PROJ_GENVIEW_MAIN, "1_VIEW", 0.025, viewDisplayStyle1);
				  quickPInstr.SetGeneralViewInstructions(generalViewInstruction1v);
                  
                  QuickPrintGeneralViewInsructions generalViewInstruction2v = 
				  wfcQuickPrint.QuickPrintGeneralViewInsructions_Create(QuickPrintGeneralViewLocation.QPRINT_PROJ_GENVIEW_MAIN, "2_VIEW", 0.025, viewDisplayStyle1);
                  quickPInstr.SetGeneralViewInstructions(generalViewInstruction2v);  
  
                  QuickPrintGeneralViewInsructions generalViewInstruction3v = 
				  wfcQuickPrint.QuickPrintGeneralViewInsructions_Create(QuickPrintGeneralViewLocation.QPRINT_PROJ_GENVIEW_MAIN, "3_VIEW", 0.025, viewDisplayStyle1);
                  quickPInstr.SetGeneralViewInstructions(generalViewInstruction3v);                  
 
				  generalViewInstruction3v = quickPInstr.GetGeneralViewInstructions();
				  
				  QuickPrintLayoutType layouttype = quickPInstr.GetLayoutType();
				  
				  QuickPrintManual3View manuallayouttype = quickPInstr.GetManualLayoutType();
				  
				  fp_out_Quick_Print.newLine();
				  fp_out_Quick_Print.write("There are total 3 views. All of them have following properties:");
   				  fp_out_Quick_Print.newLine();
				  fp_out_Quick_Print.newLine();				  
				  double scale = generalViewInstruction3v.GetScale();
				  fp_out_Quick_Print.write("Scale for each view is: " + scale);		
				  fp_out_Quick_Print.newLine();
				  fp_out_Quick_Print.newLine();					  
				  QuickPrintGeneralViewLocation genviewloc = generalViewInstruction3v.GetGeneralViewLocation();	

				  CableDisplay cabledisp = viewDisplayStyle1.GetCableDisp(); 

				  DisplayStyle dispstyle = viewDisplayStyle1.GetDispStyle();
				  
				  TangentEdgeDisplay tanedgedisp = viewDisplayStyle1.GetTanEdgeDisplay();
				  
					
				  switch(layouttype.getValue())
				  {
					case QuickPrintLayoutType._QPRINT_LAYOUT_PROJ : fp_out_Quick_Print.write("Layout Type: QPRINT_LAYOUT_PROJ");
					fp_out_Quick_Print.newLine();
					break;
					 
					case QuickPrintLayoutType._QPRINT_LAYOUT_MANUAL : fp_out_Quick_Print.write("Layout Type: QPRINT_LAYOUT_MANUAL");
					fp_out_Quick_Print.newLine();
					break;

					case QuickPrintLayoutType._QPRINT_LAYOUT_TEMPLATE : fp_out_Quick_Print.write("Layout Type: QPRINT_LAYOUT_TEMPLATE");
					fp_out_Quick_Print.newLine();
					break;

				  }

				  fp_out_Quick_Print.newLine();	
				  
				  switch(manuallayouttype.getValue())
				  {
					case QuickPrintManual3View._QPRINTMANUAL_3VIEW_1_23VERT : fp_out_Quick_Print.write("Manual Layout Type: QPRINTMANUAL_3VIEW_1_23VERT");
					fp_out_Quick_Print.newLine();
					break;
					
					case QuickPrintManual3View._QPRINTMANUAL_3VIEW_23_VERT1 : fp_out_Quick_Print.write("Manual Layout Type: QPRINTMANUAL_3VIEW_23_VERT1");
					fp_out_Quick_Print.newLine();
					break;

					case QuickPrintManual3View._QPRINTMANUAL_3VIEW_123_HORIZ : fp_out_Quick_Print.write("Manual Layout Type: QPRINTMANUAL_3VIEW_123_HORIZ");
					fp_out_Quick_Print.newLine();
					break;

				  }

				  fp_out_Quick_Print.newLine();	
				  
				  switch(cabledisp.getValue())
				  {
					case CableDisplay._CABLEDISP_DEFAULT : fp_out_Quick_Print.write("Cable Display Type: CABLEDISP_DEFAULT");
					fp_out_Quick_Print.newLine();
					break;
					
					case CableDisplay._CABLEDISP_CENTERLINE : fp_out_Quick_Print.write("Cable Display Type: CABLEDISP_CENTERLINE");
					fp_out_Quick_Print.newLine();
					break;

					case CableDisplay._CABLEDISP_THICK : fp_out_Quick_Print.write("Cable Display Type: CABLEDISP_THICK");
					fp_out_Quick_Print.newLine();
					break;
				  }

				  fp_out_Quick_Print.newLine();	

				  switch(dispstyle.getValue())
				  {
					case DisplayStyle._DISPSTYLE_DEFAULT : fp_out_Quick_Print.write("Display Style: DISPSTYLE_DEFAULT");
					fp_out_Quick_Print.newLine();
					break;
					
					case DisplayStyle._DISPSTYLE_WIREFRAME : fp_out_Quick_Print.write("Display Style: DISPSTYLE_WIREFRAME");
					fp_out_Quick_Print.newLine();
					break;

					case DisplayStyle._DISPSTYLE_HIDDEN_LINE : fp_out_Quick_Print.write("Display Style: DISPSTYLE_HIDDEN_LINE");
					fp_out_Quick_Print.newLine();
					break;

					case DisplayStyle._DISPSTYLE_NO_HIDDEN : fp_out_Quick_Print.write("Display Style: DISPSTYLE_NO_HIDDEN ");
					fp_out_Quick_Print.newLine();
					break;

					case DisplayStyle._DISPSTYLE_SHADED : fp_out_Quick_Print.write("Display Style: DISPSTYLE_SHADED");
					fp_out_Quick_Print.newLine();
					break;

					case DisplayStyle._DISPSTYLE_FOLLOW_ENVIRONMENT : fp_out_Quick_Print.write("Display Style: DISPSTYLE_FOLLOW_ENVIRONMENT");		
					fp_out_Quick_Print.newLine();
					break;

   				  }

				  fp_out_Quick_Print.newLine();	

				  switch(tanedgedisp.getValue())
				  {
					case TangentEdgeDisplay._TANEDGE_DEFAULT : fp_out_Quick_Print.write("Tangent Edge Display: TANEDGE_DEFAULT");
					fp_out_Quick_Print.newLine();
					break;

					case TangentEdgeDisplay._TANEDGE_NONE : fp_out_Quick_Print.write("Tangent Edge Display: TANEDGE_NONE");
					fp_out_Quick_Print.newLine();
					break;

					case TangentEdgeDisplay._TANEDGE_CENTERLINE : fp_out_Quick_Print.write("Tangent Edge Display: TANEDGE_CENTERLINE");
					fp_out_Quick_Print.newLine();
					break;

					case TangentEdgeDisplay._TANEDGE_PHANTOM : fp_out_Quick_Print.write("Tangent Edge Display: TANEDGE_PHANTOM");				  
					fp_out_Quick_Print.newLine();
					break;

					case TangentEdgeDisplay._TANEDGE_DIMMED : fp_out_Quick_Print.write("Tangent Edge Display: TANEDGE_DIMMED");
					fp_out_Quick_Print.newLine();
					break;

					case TangentEdgeDisplay._TANEDGE_SOLID : fp_out_Quick_Print.write("Tangent Edge Display: TANEDGE_SOLID");
					fp_out_Quick_Print.newLine();
					break;

 				  }				  
				  			 				  
				  fp_out_Quick_Print.newLine();	
				  
				  switch(genviewloc.getValue())
				  {
					case QuickPrintGeneralViewLocation._QPRINT_PROJ_GENVIEW_MAIN : fp_out_Quick_Print.write("General View Location: QPRINT_PROJ_GENVIEW_MAIN");
					fp_out_Quick_Print.newLine();
					break;
					
					case QuickPrintGeneralViewLocation._QPRINT_PROJ_GENVIEW_NW : fp_out_Quick_Print.write("General View Location: QPRINT_PROJ_GENVIEW_NW");
					fp_out_Quick_Print.newLine();
					break;

					case QuickPrintGeneralViewLocation._QPRINT_PROJ_GENVIEW_SW : fp_out_Quick_Print.write("General View Location: QPRINT_PROJ_GENVIEW_SW");
					fp_out_Quick_Print.newLine();
					break;

					case QuickPrintGeneralViewLocation._QPRINT_PROJ_GENVIEW_SE : fp_out_Quick_Print.write("General View Location: QPRINT_PROJ_GENVIEW_SE ");
					fp_out_Quick_Print.newLine();
					break;

					case QuickPrintGeneralViewLocation._QPRINT_PROJ_GENVIEW_NE : fp_out_Quick_Print.write("General View Location: QPRINT_PROJ_GENVIEW_NE");
					fp_out_Quick_Print.newLine();
					break;

   				  }
				  
				  fp_out_Quick_Print.close();
				  
                  wSolid.QuickPrint(quickPInstr, "postscript.pcf");
				  
				 
		}
		else
		{
			throw new Exception("Method: otkQuickPrint \nMsg: Model is not displayed");
		}

		 fp_out_Quick_Print.close();
      }
		catch (Exception e)
		{
			System.out.println("Exception: " + e);
		}
	}



}
